Skip to content

Label external contributions - #22568

Merged
andersfugmann merged 4 commits into
mainfrom
andersfugmann/label-external-contributions
Sep 16, 2026
Merged

andersfugmann merged 4 commits into
mainfrom
andersfugmann/label-external-contributions

Conversation

@andersfugmann

@andersfugmann andersfugmann commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

For PR's created, ready-for-review or reopened by non-owners an non-members, apply label 'external-contributer'
The workflow has pull_request_target which ensures that workflow is executed from the merge target and not the PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 15, 2026 09:35
@andersfugmann
andersfugmann requested a review from a team as a code owner September 15, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Opened-event runs can overwrite deliberate label removal while queued.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds automatic labeling for qualifying external pull requests while respecting prior label removal.

Changes:

  • Handles opened, reopened, and ready-for-review events.
  • Uses minimal permissions and a SHA-pinned action.
  • Checks label history before relabeling.
File Description
.github/​workflows/​label-external-contributions.yml Adds the external-contribution labeling workflow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/label-external-contributions.yml Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread .github/workflows/label-external-contributions.yml Outdated
oscarsj
oscarsj previously approved these changes Sep 15, 2026

@oscarsj oscarsj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! A small , nitpick suggestion for documenting the behaviour but otherwise looks good , thank you

Co-authored-by: Óscar San José <oscarsj@github.com>
@andersfugmann

Copy link
Copy Markdown
Contributor Author

Thanks for the comments. Applied your suggestion on improving documentation.
It is possible to extend the workflow to exclude any member of the GH org, but this keeps it clean and simple. We can always update later

name: Label external contributions

on:
pull_request_target:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that pull_request_target doesn't work anymore. See #22321 for the changes made to labeler.yml.

@andersfugmann andersfugmann Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Thanks. Did not know that (and apparently Copilot did not either). I'll update the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the GitHub documentation out of date then? It fits perfectly for this job.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pull_request_target is just disabled for the github org. labeler.yml was starting to fail with Event 'pull_request_target' is not allowed to trigger Actions workflows. at around point where the that PR got merged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote the workflow to use a scheduled run to inspect new PRs and apply the label.

…r the external review labeler workflow

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@andersfugmann
andersfugmann force-pushed the andersfugmann/label-external-contributions branch from 5489c2e to be6d5b7 Compare September 15, 2026 14:48
@andersfugmann
andersfugmann merged commit 4411b5e into main Sep 16, 2026
5 checks passed
@andersfugmann
andersfugmann deleted the andersfugmann/label-external-contributions branch September 16, 2026 12:16
@asgerf

asgerf commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

The label started appearing on non-external contributions such as #22591

@navntoft

Copy link
Copy Markdown
Contributor

Hmm, looks like a permission issue:

# User token with read:org access: MEMBER
gh api repos/github/codeql/pulls/22591 | jq '{author: .user.login, author_association}
# Anonymous request: CONTRIBUTOR
curl -sS https://api.github.com/repos/github/codeql/pulls/22591 | jq '{author: .user.login, author_association}'

@andersfugmann

Copy link
Copy Markdown
Contributor Author

I disabled the workflow. It's not able to determine repository membership correctly, and currently labels all new non-draft PR's. Ideally, it should check for GitHub org membership.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants